package com.shallowUniverse.process.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.shallowUniverse.process.entity.Approval;
import com.shallowUniverse.process.dto.TableField;
import com.shallowUniverse.process.dto.TableFieldCondition;
import com.shallowUniverse.process.mapper.provider.ApprovalProvider;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @author gs
 * @date create in 2020/12/11 16:27
 */
@Repository
public interface ApprovalMapper {

    @InsertProvider(type = ApprovalProvider.class, method = "save")
    @Options(keyProperty = "id", keyColumn = "id", useGeneratedKeys = true)
    int save(Approval approval);

    @SelectProvider(type = ApprovalProvider.class, method = "selectTableData")
    Map<String, Object> selectTableData(TableFieldCondition tableFieldCondition);

    @SelectProvider(type = ApprovalProvider.class, method = "selectById")
    Approval selectById(Long id);

    @SelectProvider(type = ApprovalProvider.class, method = "selectByRole")
    List<Approval> selectByRole(@Param("role") String role, @Param("appoint") Long appoint, @Param("deptId") Long deptId, Approval approval);

    @UpdateProvider(type = ApprovalProvider.class, method = "update")
    int update(Approval approval);

    @SelectProvider(type = ApprovalProvider.class, method = "selectByUser")
    List<Approval> selectByUser(@Param("id") Long id, Approval approval);

    @SelectProvider(type = ApprovalProvider.class, method = "selectTableFields")
    List<TableField> selectTableFields(String target);

    @DeleteProvider(type = ApprovalProvider.class, method = "deleteLogic")
    int deleteLogic(String id);

    @DeleteProvider(type = ApprovalProvider.class, method = "delete")
    int delete(String id);

    @UpdateProvider(type = ApprovalProvider.class, method = "updateApprovePerson")
    int updateApprovePerson(Map<String, String> params);

    @SelectProvider(type = ApprovalProvider.class, method = "selectByRole")
    IPage<Approval> selectPageByRole(IPage<Approval> page, @Param("role") String userRoles, @Param("appoint") Long appoint, @Param("deptId") Long deptId, Approval approval);

    @SelectProvider(type = ApprovalProvider.class, method = "selectByUser")
    IPage<Approval> selectPageByUser(IPage<Approval> page, @Param("id") Long id, Approval approval);

    @SelectProvider(type = ApprovalProvider.class, method = "selectList")
    List<Approval> selectList(Approval approval);

    @SelectProvider(type = ApprovalProvider.class, method = "selectList")
    IPage<Approval> selectPageList(IPage<Approval> page, Approval approval);

    @SelectProvider(type = ApprovalProvider.class, method = "selectNotCompletedByProcess")
    List<Approval> selectNotCompletedByProcess(String processId);

    @SelectProvider(type = ApprovalProvider.class, method = "selectNotCompletedByIds")
    List<Approval> selectNotCompletedByIds(String ids);

    @SelectProvider(type = ApprovalProvider.class, method = "selectNotCompletedByProcessNode")
    List<Approval> selectNotCompletedByProcessNode(String ids);
}
